package example.spring_aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @ClassName TestAnnotationMyAspect
 * @Description 自定义注解的实现
 * @Author ZJX
 * @Date 2024/9/2 19:26
 * @Version 1.0
 */

@Aspect
@Component
@Slf4j
public class TestAnnotationMyAspect {
    @Around("@annotation(example.spring_aop.config.MyAspect)")
    public Object doAround(ProceedingJoinPoint joinPoint){
        log.info("do around before...");
        Object o = null;
        try {
            o = joinPoint.proceed();
        } catch (Throwable e) {
            log.error("发生异常,e:", e);
        }
        log.info("do around after...");
        return o;
    }
}
